package com.wqtz.chechai.view.activities;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wqtz.chechai.R;
import com.wqtz.chechai.base.BaseActivity;
import com.wqtz.chechai.bean.CarResult;
import com.wqtz.chechai.presenter.BasePresent;
import com.wqtz.chechai.utils.StringUtils;
import com.wqtz.chechai.utils.ToastUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 项目名称： CheChai
 * 创建人 : Liberation
 * 创建时间: 2017/1/3 10:55
 */

public class ResultActivity extends BaseActivity {
	@BindView(R.id.iv_back)
	ImageView mIvBack;
	@BindView(R.id.tv_title)
	TextView mTvTitle;
	@BindView(R.id.iv_vin)
	ImageView mIvVin;
	@BindView(R.id.iv_pinggu)
	ImageView mIvPinggu;
	@BindView(R.id.iv_driving_info)
	ImageView mIvDrivingInfo;
	@BindView(R.id.tv_vin)
	TextView mTvVin;
	@BindView(R.id.tv_edpg)
	TextView mTvEdpg;
	@BindView(R.id.tv_carinfo)
	TextView mTvCarinfo;
	@BindView(R.id.tv_es)
	TextView mTvEs;
	@BindView(R.id.tv_car_info)
	TextView mTvCarInfo;
	@BindView(R.id.tv_buy_time)
	TextView mTvBuyTime;
	@BindView(R.id.tv_car_km)
	TextView mTvCarKm;
	@BindView(R.id.tv_chadang)
	TextView mTvChadang;
	@BindView(R.id.tv_cha_next)
	TextView mTvChaNext;
	@BindView(R.id.ll_chadang)
	LinearLayout mLlChadang;
	@BindView(R.id.tv_yugu)
	TextView mTvYugu;
	@BindView(R.id.et_assumePrice)
	EditText assume_price;
	@BindView(R.id.tv_run_km)
	TextView mTvRunKm;
	@BindView(R.id.ll_yugu)
	LinearLayout mLlYugu;
	@BindView(R.id.btn_confirm)
	Button mBtnConfirm;
	@BindView(R.id.tv_vin_error_return)
	TextView mTvVinErrorReturn;
	@BindView(R.id.tv_price1)
	TextView mTvPrice1;
	@BindView(R.id.tv_price2)
	TextView mTvPrice2;
	@BindView(R.id.tv_price3)
	TextView mTvPrice3;
	private String carVIN ;//车辆VIN码
	private String cityId;//购买地点城市ID
	private String carModelId; //车辆型号对应的ID
	private String carModel;//车辆型号
	private String year; //购买年份
	private String month;//购买月份
	private String mileage;//行驶的公里数
	private String price;//购买的价钱
	private String carStatus; //车辆状态
	private String mortgageStatus;//车辆抵押状态
	private String provinceId; //省份ID
	private Double assumPrice; //预估价格
	private String carBuyTime;//车辆购买时间
	private String price1; //个人买卖价
	private String price2;//经销商购入价
	private String price3;//经销商卖出价
	private List<Double> arrs;

	@Override
	public void init() {
		ButterKnife.bind(this);
		Intent intent = getIntent();
		cityId = intent.getStringExtra("cityId");
		provinceId = intent.getStringExtra("provinceId");
		carModelId = intent.getStringExtra("carModelId");
		carModel = intent.getStringExtra("carModel");
		carBuyTime = intent.getStringExtra("buyTime");
		mileage = intent.getStringExtra("mileage");
		carStatus = intent.getStringExtra("carStatus");
		price1 = intent.getStringExtra("price1");
		price2 = intent.getStringExtra("price2");
		price3 = intent.getStringExtra("price3");

	}

	@Override
	public void loadData() {
		mTvCarInfo.setText(carModel);
		mTvBuyTime.setText(carBuyTime);
		mTvCarKm.setText("里程: " + mileage + "万公里");
		mTvPrice1.setText(price1+"万");
		mTvPrice2.setText(price2+"万");
		mTvPrice3.setText(price3+"万");


	}

	@Override
	public int setContentViews() {
		return R.layout.activity_result;
	}

	@Override
	public BasePresent createPresenter() {
		return null;
	}


	@OnClick({R.id.iv_back, R.id.btn_confirm, R.id.tv_vin_error_return})
	public void onClick(View view) {
		switch (view.getId()) {
			case R.id.iv_back:
				break;
			case R.id.btn_confirm:
				putData();
				break;
			case R.id.tv_vin_error_return:
				finish();
				break;
		}
	}

	private void putData() {
		if(!StringUtils.isEmpty(assume_price.getText().toString())&&StringUtils.isNumeric(assume_price.getText().toString())){
			Intent intent = new Intent(this,DrivingLicenseActivity.class);
			assumPrice = Double.parseDouble(assume_price.getText().toString());
			intent.putExtra("cityId",cityId);
			intent.putExtra("provinceId",provinceId);
			intent.putExtra("carModelId",carModelId);
			intent.putExtra("carModel",carModel);
			intent.putExtra("buyTime",carBuyTime);
			intent.putExtra("mileage",mileage);
			intent.putExtra("carStatus",carStatus);
			intent.putExtra("price1",price1);
			intent.putExtra("price2",price2);
			intent.putExtra("price3",price3);
			intent.putExtra("assumPrice",assumPrice);
			startActivity(intent);

		}else {
			ToastUtils.show(this,"填写数据有误",2000);
		}

	}

	@Override
	protected void onResume() {
		super.onResume();
		activitys.add(this); //添加当前的activity
	}
}
